#pragma once
#include "MetricLearner.h"
#include "MatlabMatrix.h"
#include <vector>


using namespace matlab;
/*
This class doesn't do metric learning really. Instead, it reads the dependency from a DBN
provided by the user and uses that as the transformation. The format of the DBN file is:

the file can have several lines of the form:

action target_dim  dim1 dim2 ...

which means to predict target_dim when action is applied, we only need dim1 dim2 ... dimensions, where all the values are indexes of dimensions
if a pair of action/target_dim is not available in the DBN, the default is that they ARE dependent
*/


class DBNMetricLearner :
	public SingleVariateMetricLearner
{
public:
	DBNMetricLearner(FMLKRGeneralizer* f);
	virtual ~DBNMetricLearner(void);


	virtual void transform(Observation newst, Action a, int dim);
	virtual void transformInMatlab(ANNpointArray& data, int size, Action a, int dim);
	virtual void submitAPCChanges(int action, int dim);
	virtual int learnTransformation(ANNpointArray& data, Observation_type*& targets, int size, int action, int dim);


	void loadDependencies(const char* fname);

public:
	MatlabMatrix<int>	reducedDimensions;
	std::vector<MatlabMatrix<int>  > dependencies;			//this vector has one element for each action. each element is a matrix of size (dim X dim). if element (i,j) is 1 it means we need dim j to predict dim i
	int numberOfActions;
	int dimension;
};
